<?php
/**
* @package Pages-and-Items (com_pi_pages_and_items)
* @version 1.5.7
* @copyright Copyright (C) 2006-2010 Carsten Engel. All rights reserved.
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
* @author http://www.pages-and-items.com
*/

//no direct access
if(!defined('_VALID_MOS') && !defined('_JEXEC')){
	die('Restricted access');
}


//check if user has right to uplaod images
if(!$class_pi->checkUserActionRight(17)){
	echo '<span style="font-size: 0.7em; font-family: arial;">'._pi_lang_nouploadimage.'</span>';
	exit();
}

?>
<link href="components/com_pi_pages_and_items/css/popup.css" rel="stylesheet" type="text/css" />
<link href="components/com_pi_pages_and_items/css/pages_and_items3.css" rel="stylesheet" type="text/css" />
<style type="text/css">
html{
	overflow-x:hidden;
	overflow-y:hidden;
}
</style>
<?php
if( !defined('_JEXEC') ){//joomla version is 1.0.x so also get those red-like colors
	echo '<link href="components/com_pi_pages_and_items/css/joomla_1_0_x.css" rel="stylesheet" type="text/css" />';
}  
?>
<script language="javascript" type="text/javascript">
<!--

function validate_form(){	
	isValid = false; 
	if (document.getElementById('image').value == '') {
		alert('<?php echo _pi_lang_no_file; ?>');
		document.getElementById('image').focus();
	}else{
		isValid = true;
	}
	return isValid;	
}

-->
</script>

<form name="adminForm" method="post" action="" ENCTYPE="multipart/form-data" style="margin: 0; padding: 0;" onsubmit="return validate_form();">
		<input type="hidden" name="option" value="com_pi_pages_and_items" />
		<input type="hidden" name="task" value="image_upload_process" />		
  <table cellspacing="0" cellpadding="0" border="0" width="100%">
 
  <tr>
	  <td width="10">&nbsp;</td>
	  <td colspan="4">
	  <?php 
	  if($class_pi->get_var('message', '' )){
	  echo "<span style=\"color: #c64934;\">";	  
	  echo $class_pi->get_var('message', '' );
	  echo "</span>";
	  }
	  if($class_pi->get_var('image_uploaded', '' )){ 
	  //if($_GET['image_uploaded']){
	  $image_uploaded = $class_pi->get_var('image_uploaded', '' );	  
	  echo "<script language=\"JavaScript\">\n";
	  //echo "window.parent.frames['iframeSelect'].location.href = 'index2.php?option=com_pi_pages_and_items&task=image_select&image_uploaded=$image_uploaded#image';\n";
	  echo "window.parent.frames['iframeSelect'].location.href = 'index2.php?option=com_pi_pages_and_items&task=image_select&image_uploaded=$image_uploaded';\n";
	  echo "imagePath = 'images/stories/".$image_uploaded."';\n";
$imageSizes = ('../images/stories/'.$image_uploaded);			         
$size = getimagesize($imageSizes);
$imageHeight = $size[1];
$imageWidth = $size[0];
		echo "window.parent.document.getElementById('src').value = imagePath;\n";
		echo "window.parent.document.getElementById('alt').value = '".$image_uploaded."';\n";
		echo "window.parent.document.getElementById('border').value = '0';\n";
		echo "window.parent.document.getElementById('width').value = ".$imageWidth.";\n";
		echo "window.parent.document.getElementById('height').value = ".$imageHeight.";\n";
	  echo "</script>";
	  }
	  ?>
	  </td>
    </tr>
	
    <tr>
    <td width="10">&nbsp;</td>
	  <td width="10"><INPUT TYPE="file" value="1" NAME="image" id="image" /></td>
	<td width="10">&nbsp;</td>
	  <td width="10"><INPUT TYPE="submit" NAME="submit" VALUE="<?php echo _pi_lang_upload; ?>" /></td>
	  <td>&nbsp;</td>
	  </tr>
	  
  </table>
  
</FORM>		
